import random
from typing import List, Tuple
from constants import TASK_BATCH

from entity.processor import Processor
from entity.task import Task
from utils.rand import rand_float


def gen_test_cases() -> Tuple[List[Task], List[Processor]]:
    tasks: List[Task] = []
    processors: List[Processor] = []

    for i in range(1, 10):
        p = Processor(i)
        p.compute_ability = 1000
        processors.append(p)

    for i in range(TASK_BATCH * 50):
        task = Task(i)
        task.compute_size = rand_float(1000, 10000)
        tasks.append(task)

    sum_p = 0
    for processor in processors:
        sum_p += processor.compute_ability

    sum_t = 0
    for task in tasks:
        sum_t += task.length()

    for task in tasks:
        factor = rand_float(0.7, 1.8)
        # print(sum_t, sum_p, sum_t / sum_p * factor)
        task.deadline = sum_t / sum_p * factor

    return tasks, processors
